package web_pro;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class xcx_SP {
	
	private String SPID="";
	private String SPmingcheng="";
	private String SPjiage="";
	private String SPkucun="";
	private String SPpic="";
	
	public String getSPID() {
		return SPID;
	}
	public void setSPID(String sPID) {
		SPID = sPID;
	}
	public String getSPmingcheng() {
		return SPmingcheng;
	}
	public void setSPmingcheng(String sPmingcheng) {
		SPmingcheng = sPmingcheng;
	}
	public String getSPjiage() {
		return SPjiage;
	}
	public String setSPjiage(String sPjiage) {
		return SPjiage = sPjiage;
	}
	public String getSPkucun() {
		return SPkucun;
	}
	public String getSPkucun(String sPkucun) {
		return SPkucun = sPkucun;
	}
	public String getSPpic() {
		return SPpic;
	}
	public String getSPpic(String sPpic) {
		return SPpic = sPpic;
	}
	
	public String xcx_SPlist() {
    	Connection  conn = pub_fun.getConnection();
    	String Sql_str = "select * from xcx_sp_data order by SPID ";
		String json01="[";
    	try {
			PreparedStatement pstat = conn.prepareStatement(Sql_str);
			ResultSet rs = (ResultSet) pstat.executeQuery();
			while(rs.next())  
	            {
						json01= json01+"{\"SPID\":\""+rs.getString("SPID") +"\",\"SPMC\":\""+rs.getString("SPMC")+"\", \"SPJG\":\""+rs.getString("SPJG")+"\", \"SPKC\":\""+rs.getString("SPKC")+"\", \"SPPIC\":\""+rs.getString("SPPIC")+"\"},";
						
				}
			json01=json01+"]";
			System.out.print(json01);
	        pstat.close();
	        conn.close();

 
        } catch (SQLException e) {
            e.printStackTrace();
        }
    	json01 = json01.replace("},]", "}]");
		return json01;

	}
	
	public String xcx_SPinfo(String VSPID) {
		Connection conn = pub_fun.getConnection();
    	String Sql_str = "select * from xcx_sp_data where SPID="+VSPID+" ";
		String json01="";
    	try {
			PreparedStatement pstat = conn.prepareStatement(Sql_str);
			ResultSet rs = (ResultSet) pstat.executeQuery();
			while(rs.next())  
	        {  
				json01="[{\"SPID\":\""+rs.getString("SPID") +"\",\"SPMC\":\""+rs.getString("SPMC")+"\", \"SPJG\":\""+rs.getString("SPJG")+"\", \"SPKC\":\""+rs.getString("SPKC")+"\", \"SPPIC\":\""+rs.getString("SPPIC")+"\"}]";
		    }  
	        pstat.close();
	        conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }

		return json01;
	}
}
